home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / SCSI.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  60KB  |  1,367 lines

  1. /*
  2.      File:        SCSI.h
  3.  
  4.      Contains:    SCSI Family Interfaces.
  5.  
  6.      Version:    Technology:    System 8.0
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __SCSI__
  19. #define __SCSI__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #if FOR_SYSTEM8_PREEMPTIVE
  28. #ifndef __KERNEL__
  29. #include <Kernel.h>
  30. #endif
  31. #ifndef __NAMEREGISTRY__
  32. #include <NameRegistry.h>
  33. #endif
  34. #ifndef __IOITERATOR__
  35. #include <IOIterator.h>
  36. #endif
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT_SUPPORTED
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_ALIGN_SUPPORTED
  48. #pragma options align=mac68k
  49. #endif
  50.  
  51. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  52. /* SCSI Manager errors */
  53.  
  54. enum {
  55.     scCommErr                    = 2,                            /* communications error, operation timeout */
  56.     scArbNBErr                    = 3,                            /* arbitration timeout waiting for not BSY */
  57.     scBadParmsErr                = 4,                            /* bad parameter or TIB opcode */
  58.     scPhaseErr                    = 5,                            /* SCSI bus not in correct phase for attempted operation */
  59.     scCompareErr                = 6,                            /* data compare error */
  60.     scMgrBusyErr                = 7,                            /* SCSI Manager busy  */
  61.     scSequenceErr                = 8,                            /* attempted operation is out of sequence */
  62.     scBusTOErr                    = 9,                            /* CPU bus timeout */
  63.     scComplPhaseErr                = 10                            /* SCSI bus wasn't in Status phase */
  64. };
  65.  
  66. #endif
  67. #if FOR_SYSTEM7_ONLY
  68. /* TIB opcodes */
  69.  
  70. enum {
  71.     scInc                        = 1,
  72.     scNoInc                        = 2,
  73.     scAdd                        = 3,
  74.     scMove                        = 4,
  75.     scLoop                        = 5,
  76.     scNop                        = 6,
  77.     scStop                        = 7,
  78.     scComp                        = 8
  79. };
  80.  
  81. /* Signatures */
  82.  
  83. enum {
  84.     sbSIGWord                    = 0x4552,                        /* signature word for Block 0 ('ER') */
  85.     sbMac                        = 1,                            /* system type for Mac */
  86.     pMapSIG                        = 0x504D,                        /* partition map signature ('PM') */
  87.     pdSigWord                    = 0x5453
  88. };
  89.  
  90.  
  91. enum {
  92.     oldPMSigWord                = pdSigWord,
  93.     newPMSigWord                = pMapSIG
  94. };
  95.  
  96. /* Driver Descriptor Map */
  97. struct Block0 {
  98.     unsigned short                     sbSig;                        /* unique value for SCSI block 0 */
  99.     unsigned short                     sbBlkSize;                    /* block size of device */
  100.     unsigned long                     sbBlkCount;                    /* number of blocks on device */
  101.     unsigned short                     sbDevType;                    /* device type */
  102.     unsigned short                     sbDevId;                    /* device id */
  103.     unsigned long                     sbData;                        /* not used */
  104.     unsigned short                     sbDrvrCount;                /* driver descriptor count */
  105.     unsigned long                     ddBlock;                    /* 1st driver's starting block */
  106.     unsigned short                     ddSize;                        /* size of 1st driver (512-byte blks) */
  107.     unsigned short                     ddType;                        /* system type (1 for Mac+) */
  108.     unsigned short                     ddPad[243];                    /* ARRAY[0..242] OF INTEGER; not used */
  109. };
  110. typedef struct Block0 Block0;
  111.  
  112. /*Driver descriptor*/
  113. struct DDMap {
  114.     unsigned long                     ddBlock;                    /* 1st driver's starting block */
  115.     unsigned short                     ddSize;                        /* size of 1st driver (512-byte blks) */
  116.     unsigned short                     ddType;                        /* system type (1 for Mac+) */
  117. };
  118. typedef struct DDMap DDMap;
  119.  
  120. /* Partition Map Entry */
  121. struct Partition {
  122.     unsigned short                     pmSig;                        /* unique value for map entry blk */
  123.     unsigned short                     pmSigPad;                    /* currently unused */
  124.     unsigned long                     pmMapBlkCnt;                /* # of blks in partition map */
  125.     unsigned long                     pmPyPartStart;                /* physical start blk of partition */
  126.     unsigned long                     pmPartBlkCnt;                /* # of blks in this partition */
  127.     unsigned char                     pmPartName[32];                /* ASCII partition name */
  128.     unsigned char                     pmParType[32];                /* ASCII partition type */
  129.     unsigned long                     pmLgDataStart;                /* log. # of partition's 1st data blk */
  130.     unsigned long                     pmDataCnt;                    /* # of blks in partition's data area */
  131.     unsigned long                     pmPartStatus;                /* bit field for partition status */
  132.     unsigned long                     pmLgBootStart;                /* log. blk of partition's boot code */
  133.     unsigned long                     pmBootSize;                    /* number of bytes in boot code */
  134.     unsigned long                     pmBootAddr;                    /* memory load address of boot code */
  135.     unsigned long                     pmBootAddr2;                /* currently unused */
  136.     unsigned long                     pmBootEntry;                /* entry point of boot code */
  137.     unsigned long                     pmBootEntry2;                /* currently unused */
  138.     unsigned long                     pmBootCksum;                /* checksum of boot code */
  139.     unsigned char                     pmProcessor[16];            /* ASCII for the processor type */
  140.     unsigned short                     pmPad[188];                    /* ARRAY[0..187] OF INTEGER; not used */
  141. };
  142. typedef struct Partition Partition;
  143.  
  144. /* TIB instruction */
  145. struct SCSIInstr {
  146.     unsigned short                     scOpcode;
  147.     long                             scParam1;
  148.     long                             scParam2;
  149. };
  150. typedef struct SCSIInstr SCSIInstr;
  151.  
  152. /* SCSI Phases (used by SIMs to support the Original SCSI Manager */
  153.  
  154. enum {
  155.     kDataOutPhase                = 0,                            /* Encoded MSG, C/D, I/O bits */
  156.     kDataInPhase                = 1,
  157.     kCommandPhase                = 2,
  158.     kStatusPhase                = 3,
  159.     kPhaseIllegal0                = 4,
  160.     kPhaseIllegal1                = 5,
  161.     kMessageOutPhase            = 6,
  162.     kMessageInPhase                = 7,
  163.     kBusFreePhase                = 8,                            /* Additional Phases */
  164.     kArbitratePhase                = 9,
  165.     kSelectPhase                = 10,
  166.     kMessageInPhaseNACK            = 11                            /* Message In Phase with ACK hanging on the bus */
  167. };
  168.  
  169. extern pascal OSErr SCSIReset(void )
  170.  TWOWORDINLINE(0x4267, 0xA815);
  171.  
  172. extern pascal OSErr SCSIGet(void )
  173.  THREEWORDINLINE(0x3F3C, 0x0001, 0xA815);
  174.  
  175. extern pascal OSErr SCSISelect(short targetID)
  176.  THREEWORDINLINE(0x3F3C, 0x0002, 0xA815);
  177.  
  178. extern pascal OSErr SCSICmd(Ptr buffer, short count)
  179.  THREEWORDINLINE(0x3F3C, 0x0003, 0xA815);
  180.  
  181. extern pascal OSErr SCSIRead(Ptr tibPtr)
  182.  THREEWORDINLINE(0x3F3C, 0x0005, 0xA815);
  183.  
  184. extern pascal OSErr SCSIRBlind(Ptr tibPtr)
  185.  THREEWORDINLINE(0x3F3C, 0x0008, 0xA815);
  186.  
  187. extern pascal OSErr SCSIWrite(Ptr tibPtr)
  188.  THREEWORDINLINE(0x3F3C, 0x0006, 0xA815);
  189.  
  190. extern pascal OSErr SCSIWBlind(Ptr tibPtr)
  191.  THREEWORDINLINE(0x3F3C, 0x0009, 0xA815);
  192.  
  193. extern pascal OSErr SCSIComplete(short *stat, short *message, unsigned long wait)
  194.  THREEWORDINLINE(0x3F3C, 0x0004, 0xA815);
  195.  
  196. extern pascal short SCSIStat(void )
  197.  THREEWORDINLINE(0x3F3C, 0x000A, 0xA815);
  198.  
  199. extern pascal OSErr SCSISelAtn(short targetID)
  200.  THREEWORDINLINE(0x3F3C, 0x000B, 0xA815);
  201.  
  202. extern pascal OSErr SCSIMsgIn(short *message)
  203.  THREEWORDINLINE(0x3F3C, 0x000C, 0xA815);
  204.  
  205. extern pascal OSErr SCSIMsgOut(short message)
  206.  THREEWORDINLINE(0x3F3C, 0x000D, 0xA815);
  207.  
  208.  
  209. enum {
  210.     scsiVERSION                    = 43
  211. };
  212.  
  213. #endif
  214. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  215. /* SCSI Callback Procedure Prototypes */
  216. typedef void (*AENCallbackProcPtr)(void );
  217. typedef OSErr (*SIMInitProcPtr)(Ptr SIMinfoPtr);
  218. typedef void (*SIMActionProcPtr)(void *scsiPB, Ptr SIMGlobals);
  219. typedef void (*SCSIProcPtr)(void );
  220. typedef void (*SCSIMakeCallbackProcPtr)(void *scsiPB);
  221. /* SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility */
  222. typedef long (*SCSIInterruptPollProcPtr)(Ptr SIMGlobals);
  223. typedef long (*SCSIInterruptProcPtr)(Ptr SIMGlobals);
  224.  
  225. #if GENERATINGCFM
  226. typedef UniversalProcPtr AENCallbackUPP;
  227. typedef UniversalProcPtr SIMInitUPP;
  228. typedef UniversalProcPtr SIMActionUPP;
  229. typedef UniversalProcPtr SCSIUPP;
  230. typedef UniversalProcPtr SCSIMakeCallbackUPP;
  231. typedef UniversalProcPtr SCSIInterruptPollUPP;
  232. typedef UniversalProcPtr SCSIInterruptUPP;
  233. #else
  234. typedef AENCallbackProcPtr AENCallbackUPP;
  235. typedef SIMInitProcPtr SIMInitUPP;
  236. typedef SIMActionProcPtr SIMActionUPP;
  237. typedef SCSIProcPtr SCSIUPP;
  238. typedef SCSIMakeCallbackProcPtr SCSIMakeCallbackUPP;
  239. typedef SCSIInterruptPollProcPtr SCSIInterruptPollUPP;
  240. typedef SCSIInterruptProcPtr SCSIInterruptUPP;
  241. #endif
  242. #endif
  243. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  244. typedef pascal void (*SCSICallbackProcPtr)(void *scsiPB);
  245.  
  246. #if GENERATINGCFM
  247. typedef UniversalProcPtr SCSICallbackUPP;
  248. #else
  249. typedef SCSICallbackProcPtr SCSICallbackUPP;
  250. #endif
  251. #endif
  252. #if FOR_SYSTEM7_ONLY
  253.  
  254. enum {
  255.     uppAENCallbackProcInfo = kCStackBased,
  256.     uppSIMInitProcInfo = kCStackBased
  257.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  258.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr))),
  259.     uppSIMActionProcInfo = kCStackBased
  260.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
  261.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr))),
  262.     uppSCSIProcInfo = kCStackBased,
  263.     uppSCSIMakeCallbackProcInfo = kCStackBased
  264.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *))),
  265.     uppSCSIInterruptPollProcInfo = kCStackBased
  266.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  267.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr))),
  268.     uppSCSIInterruptProcInfo = kCStackBased
  269.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  270.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr))),
  271.     uppSCSICallbackProcInfo = kPascalStackBased
  272.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
  273. };
  274.  
  275. #if GENERATINGCFM
  276. #define NewAENCallbackProc(userRoutine)        \
  277.         (AENCallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppAENCallbackProcInfo, GetCurrentArchitecture())
  278. #define NewSIMInitProc(userRoutine)        \
  279.         (SIMInitUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMInitProcInfo, GetCurrentArchitecture())
  280. #define NewSIMActionProc(userRoutine)        \
  281.         (SIMActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMActionProcInfo, GetCurrentArchitecture())
  282. #define NewSCSIProc(userRoutine)        \
  283.         (SCSIUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIProcInfo, GetCurrentArchitecture())
  284. #define NewSCSIMakeCallbackProc(userRoutine)        \
  285.         (SCSIMakeCallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIMakeCallbackProcInfo, GetCurrentArchitecture())
  286. #define NewSCSIInterruptPollProc(userRoutine)        \
  287.         (SCSIInterruptPollUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptPollProcInfo, GetCurrentArchitecture())
  288. #define NewSCSIInterruptProc(userRoutine)        \
  289.         (SCSIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptProcInfo, GetCurrentArchitecture())
  290. #define NewSCSICallbackProc(userRoutine)        \
  291.         (SCSICallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSICallbackProcInfo, GetCurrentArchitecture())
  292. #else
  293. #define NewAENCallbackProc(userRoutine)        \
  294.         ((AENCallbackUPP) (userRoutine))
  295. #define NewSIMInitProc(userRoutine)        \
  296.         ((SIMInitUPP) (userRoutine))
  297. #define NewSIMActionProc(userRoutine)        \
  298.         ((SIMActionUPP) (userRoutine))
  299. #define NewSCSIProc(userRoutine)        \
  300.         ((SCSIUPP) (userRoutine))
  301. #define NewSCSIMakeCallbackProc(userRoutine)        \
  302.         ((SCSIMakeCallbackUPP) (userRoutine))
  303. #define NewSCSIInterruptPollProc(userRoutine)        \
  304.         ((SCSIInterruptPollUPP) (userRoutine))
  305. #define NewSCSIInterruptProc(userRoutine)        \
  306.         ((SCSIInterruptUPP) (userRoutine))
  307. #define NewSCSICallbackProc(userRoutine)        \
  308.         ((SCSICallbackUPP) (userRoutine))
  309. #endif
  310.  
  311. #if GENERATINGCFM
  312. #define CallAENCallbackProc(userRoutine)        \
  313.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppAENCallbackProcInfo)
  314. #define CallSIMInitProc(userRoutine, SIMinfoPtr)        \
  315.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIMInitProcInfo, (SIMinfoPtr))
  316. #define CallSIMActionProc(userRoutine, scsiPB, SIMGlobals)        \
  317.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIMActionProcInfo, (scsiPB), (SIMGlobals))
  318. #define CallSCSIProc(userRoutine)        \
  319.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIProcInfo)
  320. #define CallSCSIMakeCallbackProc(userRoutine, scsiPB)        \
  321.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIMakeCallbackProcInfo, (scsiPB))
  322. #define CallSCSIInterruptPollProc(userRoutine, SIMGlobals)        \
  323.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIInterruptPollProcInfo, (SIMGlobals))
  324. #define CallSCSIInterruptProc(userRoutine, SIMGlobals)        \
  325.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIInterruptProcInfo, (SIMGlobals))
  326. #define CallSCSICallbackProc(userRoutine, scsiPB)        \
  327.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSICallbackProcInfo, (scsiPB))
  328. #else
  329. #define CallAENCallbackProc(userRoutine)        \
  330.         (*(userRoutine))()
  331. #define CallSIMInitProc(userRoutine, SIMinfoPtr)        \
  332.         (*(userRoutine))((SIMinfoPtr))
  333. #define CallSIMActionProc(userRoutine, scsiPB, SIMGlobals)        \
  334.         (*(userRoutine))((scsiPB), (SIMGlobals))
  335. #define CallSCSIProc(userRoutine)        \
  336.         (*(userRoutine))()
  337. #define CallSCSIMakeCallbackProc(userRoutine, scsiPB)        \
  338.         (*(userRoutine))((scsiPB))
  339. #define CallSCSIInterruptPollProc(userRoutine, SIMGlobals)        \
  340.         (*(userRoutine))((SIMGlobals))
  341. #define CallSCSIInterruptProc(userRoutine, SIMGlobals)        \
  342.         (*(userRoutine))((SIMGlobals))
  343. #define CallSCSICallbackProc(userRoutine, scsiPB)        \
  344.         (*(userRoutine))((scsiPB))
  345. #endif
  346. #endif
  347. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  348. /* SCSI Manager function codes */
  349.  
  350. enum {
  351.     SCSINop                        = 0x00,                            /* Execute nothing                                         */
  352.     SCSIExecIO                    = 0x01,                            /* Execute the specified IO                             */
  353.     SCSIBusInquiry                = 0x03,                            /* Get parameters for entire path of HBAs                 */
  354.     SCSIReleaseQ                = 0x04,                            /* Release the frozen SIM queue for particular LUN         */
  355.     SCSIAbortCommand            = 0x10,                            /* Abort the selected Control Block                      */
  356.     SCSIResetBus                = 0x11,                            /* Reset the SCSI bus                                      */
  357.     SCSIResetDevice                = 0x12,                            /* Reset the SCSI device                                  */
  358.     SCSITerminateIO                = 0x13,                            /* Terminate any pending IO                              */
  359.     SCSIGetVirtualIDInfo        = 0x80,                            /* Find out which bus old ID is on                         */
  360.     SCSILoadDriver                = 0x82,                            /* Load a driver for a device ident                     */
  361.     SCSIOldCall                    = 0x84,                            /* XPT->SIM private call for old-API                     */
  362.     SCSICreateRefNumXref        = 0x85,                            /* Register a DeviceIdent to drvr RefNum xref             */
  363.     SCSILookupRefNumXref        = 0x86,                            /* Get DeviceIdent to drvr RefNum xref                     */
  364.     SCSIRemoveRefNumXref        = 0x87,                            /* Remove a DeviceIdent to drvr RefNum xref             */
  365.     SCSIRegisterWithNewXPT        = 0x88,                            /* XPT has changed - SIM needs to re-register itself     */
  366.     vendorUnique                = 0xC0                            /* 0xC0 thru 0xFF */
  367. };
  368.  
  369. /* Define DeviceIdent structure */
  370. struct DeviceIdent {
  371.     UInt8                             diReserved;                    /* reserved                 */
  372.     UInt8                             bus;                        /* SCSI - Bus Number        */
  373.     UInt8                             targetID;                    /* SCSI - Target SCSI ID    */
  374.     UInt8                             LUN;                        /* SCSI - LUN                  */
  375. };
  376. typedef struct DeviceIdent DeviceIdent;
  377.  
  378. /*
  379.  #endif // FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  380.  #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  381. */
  382. /* Allocation length defines for some of the fields */
  383.  
  384. enum {
  385.     handshakeDataLength            = 8,                            /* Handshake data length */
  386.     maxCDBLength                = 16,                            /* Space for the CDB bytes/pointer */
  387.     vendorIDLength                = 16                            /* ASCII string len for Vendor ID  */
  388. };
  389.  
  390. typedef unsigned char *SCSIDataPtr;
  391. /* Command Descriptor Block structure */
  392. union CDB {
  393.     BytePtr                         cdbPtr;                        /* pointer to the CDB, or */
  394.     UInt8                             cdbBytes[16];                /* the actual CDB to send */
  395. };
  396. typedef union CDB CDB;
  397.  
  398. typedef CDB *CDBPtr;
  399. /* Scatter/gather list element */
  400. struct SGRecord {
  401.     Ptr                             SGAddr;
  402.     UInt32                             SGCount;
  403. };
  404. typedef struct SGRecord SGRecord;
  405.  
  406. /*
  407.  #endif    // FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  408.  #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  409. */
  410. struct SCSIHdr {
  411.     struct SCSIHdr *                qLink;                        /* (internal use, must be nil on entry)    */
  412.     short                             scsiReserved1;                /* ->     reserved for input                */
  413.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  414.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  415.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  416.     OSErr                             scsiResult;                    /* <- Returned result                     */
  417.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  418.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  419.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  420.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  421.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  422.     long                             scsiReserved3;                /* reserved                                */
  423. };
  424. typedef struct SCSIHdr SCSIHdr;
  425.  
  426. struct SCSI_PB {
  427.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  428.     short                             scsiReserved1;                /* ->     reserved for input                */
  429.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  430.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  431.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  432.     OSErr                             scsiResult;                    /* <- Returned result                     */
  433.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  434.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  435.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  436.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  437.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  438.     long                             scsiReserved3;                /* reserved                                */
  439. };
  440. typedef struct SCSI_PB SCSI_PB;
  441.  
  442. /*
  443.  #endif    // FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  444.   This is temporary until we have connection protocol ready.
  445.  #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  446. */
  447. struct SCSI_IO {
  448.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  449.     short                             scsiReserved1;                /* ->     reserved for input                */
  450.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  451.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  452.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  453.     OSErr                             scsiResult;                    /* <- Returned result                     */
  454.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  455.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  456.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  457.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  458.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  459.     long                             scsiReserved3;                /* reserved                                */
  460.  
  461.     UInt16                             scsiResultFlags;            /* <- Flags which modify the scsiResult field        */
  462.     UInt16                             scsiReserved3pt5;            /* -> Reserved                                        */
  463.     BytePtr                         scsiDataPtr;                /* -> Pointer to the data buffer or the S/G list      */
  464.     UInt32                             scsiDataLength;                /* -> Data transfer length                            */
  465.     BytePtr                         scsiSensePtr;                /* -> Ptr to autosense data buffer                  */
  466.     UInt8                             scsiSenseLength;            /* -> size of the autosense buffer                     */
  467.     UInt8                             scsiCDBLength;                /* -> Number of bytes for the CDB                      */
  468.     UInt16                             scsiSGListCount;            /* -> num of scatter gather list entries              */
  469.     UInt32                             scsiReserved4;                /* <-     reserved for output                            */
  470.     UInt8                             scsiSCSIstatus;                /* <- Returned scsi device status                      */
  471.     SInt8                             scsiSenseResidual;            /* <- Autosense residual length                      */
  472.     UInt16                             scsiReserved5;                /* <-     reserved for output                             */
  473.     long                             scsiDataResidual;            /* <- Returned Transfer residual length              */
  474.     CDB                             scsiCDB;                    /* -> Actual CDB or pointer to CDB                  */
  475.     long                             scsiTimeout;                /* -> Timeout value (Time Mgr format) (CAM timeout) */
  476.     BytePtr                         scsiReserved5pt5;            /* -> Reserved                                        */
  477.     UInt16                             scsiReserved5pt6;            /* -> Reserved                                        */
  478.     UInt16                             scsiIOFlags;                /* -> additional I/O flags                               */
  479.     UInt8                             scsiTagAction;                /* -> What to do for tag queuing                       */
  480.     UInt8                             scsiReserved6;                /* ->     reserved for input                             */
  481.     UInt16                             scsiReserved7;                /* ->     reserved for input                             */
  482.     UInt16                             scsiSelectTimeout;            /* -> Select timeout value                             */
  483.     UInt8                             scsiDataType;                /* -> Data description type (i.e. buffer, TIB, S/G)    */
  484.     UInt8                             scsiTransferType;            /* -> Transfer type (i.e. Blind vs Polled)             */
  485.     UInt32                             scsiReserved8;                /* ->     reserved for input                             */
  486.     UInt32                             scsiReserved9;                /* ->     reserved for input                             */
  487.     UInt16                             scsiHandshake[8];            /* -> handshaking points (null term'd)    */
  488.     UInt32                             scsiReserved10;                /* ->     reserved for input                             */
  489.     UInt32                             scsiReserved11;                /* ->   reserved for input                            */
  490.     struct SCSI_IO *                scsiCommandLink;            /* -> Ptr to the next PB in linked cmd chain         */
  491.  
  492.     UInt8                             scsiSIMpublics[8];            /* ->     reserved for input to 3rd-party SIMs        */
  493.     UInt8                             scsiAppleReserved6[8];        /* ->    reserved for input                              */
  494.  
  495.                                                                 /* XPT layer privates (for old-API emulation) */
  496.  
  497.     UInt16                             scsiCurrentPhase;            /* <- phase upon completing old call                  */
  498.     short                             scsiSelector;                /* -> selector specified in old calls                  */
  499.     OSErr                             scsiOldCallResult;            /* <- result of old call                              */
  500.     UInt8                             scsiSCSImessage;            /* <- Returned scsi device message (for SCSIComplete)*/
  501.     UInt8                             XPTprivateFlags;            /* <> various flags                                   */
  502.     UInt8                             XPTextras[12];                /*                                                    */
  503. };
  504. typedef struct SCSI_IO SCSI_IO;
  505.  
  506. typedef SCSI_IO SCSIExecIOPB;
  507. /* Bus inquiry PB */
  508. struct SCSIBusInquiryPB {
  509.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  510.     short                             scsiReserved1;                /* ->     reserved for input                */
  511.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  512.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  513.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  514.     OSErr                             scsiResult;                    /* <- Returned result                     */
  515.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  516.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  517.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  518.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  519.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  520.     long                             scsiReserved3;                /* reserved                                */
  521.  
  522.     UInt16                             scsiEngineCount;            /* <- Number of engines on HBA                         */
  523.     UInt16                             scsiMaxTransferType;        /* <- Number of transfer types for this HBA            */
  524.  
  525.     UInt32                             scsiDataTypes;                /* <- which data types are supported by this SIM     */
  526.  
  527.     UInt16                             scsiIOpbSize;                /* <- Size of SCSI_IO PB for this SIM/HBA             */
  528.     UInt16                             scsiMaxIOpbSize;            /* <- Size of max SCSI_IO PB for all SIM/HBAs         */
  529.  
  530.     UInt32                             scsiFeatureFlags;            /* <- Supported features flags field                 */
  531.  
  532.     UInt8                             scsiVersionNumber;            /* <- Version number for the SIM/HBA                 */
  533.     UInt8                             scsiHBAInquiry;                /* <- Mimic of INQ byte 7 for the HBA                 */
  534.     UInt8                             scsiTargetModeFlags;        /* <- Flags for target mode support                 */
  535.     UInt8                             scsiScanFlags;                /* <- Scan related feature flags                     */
  536.  
  537.     UInt32                             scsiSIMPrivatesPtr;            /* <- Ptr to SIM private data area                     */
  538.     UInt32                             scsiSIMPrivatesSize;        /* <- Size of SIM private data area                 */
  539.     UInt32                             scsiAsyncFlags;                /* <- Event cap. for Async Callback                 */
  540.  
  541.     UInt8                             scsiHiBusID;                /* <- Highest path ID in the subsystem              */
  542.     UInt8                             scsiInitiatorID;            /* <- ID of the HBA on the SCSI bus                 */
  543.     UInt16                             scsiBIReserved0;            /*                                                    */
  544.  
  545.     UInt32                             scsiBIReserved1;            /* <-                                                  */
  546.     UInt32                             scsiFlagsSupported;            /* <- which scsiFlags are supported                 */
  547.  
  548.     UInt16                             scsiIOFlagsSupported;        /* <- which scsiIOFlags are supported                 */
  549.     UInt16                             scsiWeirdStuff;                /* <-                                                 */
  550.     UInt16                             scsiMaxTarget;                /* <- maximum Target number supported                 */
  551.     UInt16                             scsiMaxLUN;                    /* <- maximum Logical Unit number supported         */
  552.  
  553.     char                             scsiSIMVendor[16];            /* <- Vendor ID of SIM (or XPT if bus<FF)         */
  554.     char                             scsiHBAVendor[16];            /* <- Vendor ID of the HBA                         */
  555.     char                             scsiControllerFamily[16];    /* <- Family of SCSI Controller                 */
  556.     char                             scsiControllerType[16];        /* <- Specific Model of SCSI Controller used     */
  557.  
  558.     char                             scsiXPTversion[4];            /* <- version number of XPT                         */
  559.     char                             scsiSIMversion[4];            /* <- version number of SIM                         */
  560.     char                             scsiHBAversion[4];            /* <- version number of HBA                         */
  561.  
  562.     UInt8                             scsiHBAslotType;            /* <- type of "slot" that this HBA is in            */
  563.     UInt8                             scsiHBAslotNumber;            /* <- slot number of this HBA                         */
  564.     UInt16                             scsiSIMsRsrcID;                /* <- resource ID of this SIM                         */
  565.  
  566.     UInt16                             scsiBIReserved3;            /* <-                                                 */
  567.     UInt16                             scsiAdditionalLength;        /* <- additional BusInquiry PB len                    */
  568. };
  569. typedef struct SCSIBusInquiryPB SCSIBusInquiryPB;
  570.  
  571. /* Abort SIM Request PB */
  572. struct SCSIAbortCommandPB {
  573.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  574.     short                             scsiReserved1;                /* ->     reserved for input                */
  575.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  576.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  577.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  578.     OSErr                             scsiResult;                    /* <- Returned result                     */
  579.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  580.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  581.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  582.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  583.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  584.     long                             scsiReserved3;                /* reserved                                */
  585.     SCSI_IO *                        scsiIOptr;                    /* Pointer to the PB to abort            */
  586. };
  587. typedef struct SCSIAbortCommandPB SCSIAbortCommandPB;
  588.  
  589. /* Terminate I/O Process Request PB */
  590. struct SCSITerminateIOPB {
  591.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  592.     short                             scsiReserved1;                /* ->     reserved for input                */
  593.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  594.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  595.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  596.     OSErr                             scsiResult;                    /* <- Returned result                     */
  597.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  598.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  599.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  600.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  601.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  602.     long                             scsiReserved3;                /* reserved                                */
  603.     SCSI_IO *                        scsiIOptr;                    /* Pointer to the PB to terminate         */
  604. };
  605. typedef struct SCSITerminateIOPB SCSITerminateIOPB;
  606.  
  607. /* Reset SCSI Bus PB */
  608. struct SCSIResetBusPB {
  609.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  610.     short                             scsiReserved1;                /* ->     reserved for input                */
  611.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  612.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  613.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  614.     OSErr                             scsiResult;                    /* <- Returned result                     */
  615.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  616.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  617.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  618.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  619.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  620.     long                             scsiReserved3;                /* reserved                                */
  621. };
  622. typedef struct SCSIResetBusPB SCSIResetBusPB;
  623.  
  624. /* Reset SCSI Device PB */
  625. struct SCSIResetDevicePB {
  626.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  627.     short                             scsiReserved1;                /* ->     reserved for input                */
  628.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  629.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  630.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  631.     OSErr                             scsiResult;                    /* <- Returned result                     */
  632.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  633.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  634.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  635.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  636.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  637.     long                             scsiReserved3;                /* reserved                                */
  638. };
  639. typedef struct SCSIResetDevicePB SCSIResetDevicePB;
  640.  
  641. /* Release SIM Queue PB */
  642. struct SCSIReleaseQPB {
  643.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  644.     short                             scsiReserved1;                /* ->     reserved for input                */
  645.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  646.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  647.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  648.     OSErr                             scsiResult;                    /* <- Returned result                     */
  649.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  650.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  651.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  652.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  653.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  654.     long                             scsiReserved3;                /* reserved                                */
  655. };
  656. typedef struct SCSIReleaseQPB SCSIReleaseQPB;
  657.  
  658. #endif
  659. #if FOR_SYSTEM7_ONLY
  660. /* SCSI Get Virtual ID Info PB */
  661. struct SCSIGetVirtualIDInfoPB {
  662.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  663.     short                             scsiReserved1;                /* ->     reserved for input                */
  664.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  665.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  666.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  667.     OSErr                             scsiResult;                    /* <- Returned result                     */
  668.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  669.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  670.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  671.     Ptr                             scsiDriverStorage;            /* <> Ptr for driver private use        */
  672.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  673.     long                             scsiReserved3;                /* reserved                                */
  674.     UInt16                             scsiOldCallID;                /* -> SCSI ID of device in question     */
  675.     Boolean                         scsiExists;                    /* <- true if device exists             */
  676.     SInt8                             filler;
  677. };
  678. typedef struct SCSIGetVirtualIDInfoPB SCSIGetVirtualIDInfoPB;
  679.  
  680. /* Create/Lookup/Remove RefNum for Device PB */
  681. struct SCSIDriverPB {
  682.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  683.     short                             scsiReserved1;                /* ->     reserved for input                */
  684.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  685.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  686.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  687.     OSErr                             scsiResult;                    /* <- Returned result                     */
  688.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  689.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  690.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  691.     Ptr                             scsiDriverStorage;            /* <> Ptr for driver private use        */
  692.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  693.     long                             scsiReserved3;                /* reserved                                */
  694.     short                             scsiDriver;                    /* -> DriverRefNum, For SetDriver, <- For GetNextDriver */
  695.     UInt16                             scsiDriverFlags;            /* <> Details of driver/device             */
  696.     DeviceIdent                     scsiNextDevice;                /* <- DeviceIdent of the NEXT Item in the list  */
  697. };
  698. typedef struct SCSIDriverPB SCSIDriverPB;
  699.  
  700. /* Load Driver PB */
  701. struct SCSILoadDriverPB {
  702.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  703.     short                             scsiReserved1;                /* ->     reserved for input                */
  704.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  705.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  706.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  707.     OSErr                             scsiResult;                    /* <- Returned result                     */
  708.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  709.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  710.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  711.     Ptr                             scsiDriverStorage;            /* <> Ptr for driver private use        */
  712.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  713.     long                             scsiReserved3;                /* reserved                                */
  714.     short                             scsiLoadedRefNum;            /* <- SIM returns refnum of driver         */
  715.     Boolean                         scsiDiskLoadFailed;            /* -> if true, indicates call after failure to load */
  716.     SInt8                             filler;
  717. };
  718. typedef struct SCSILoadDriverPB SCSILoadDriverPB;
  719.  
  720. #endif
  721. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  722. /* Defines for the scsiTransferType field */
  723.  
  724. enum {
  725.     scsiTransferBlind            = 0,
  726.     scsiTransferPolled            = 1
  727. };
  728.  
  729.  
  730. enum {
  731.     scsiErrorBase                = -7936
  732. };
  733.  
  734.  
  735. enum {
  736.     scsiRequestInProgress        = 1,                            /* 1     = PB request is in progress             */
  737.                                                                 /* Execution failed  00-2F */
  738.     scsiRequestAborted            = scsiErrorBase + 2,            /* -7934 = PB request aborted by the host         */
  739.     scsiUnableToAbort            = scsiErrorBase + 3,            /* -7933 = Unable to Abort PB request             */
  740.     scsiNonZeroStatus            = scsiErrorBase + 4,            /* -7932 = PB request completed with an err     */
  741.     scsiUnused05                = scsiErrorBase + 5,            /* -7931 =                                      */
  742.     scsiUnused06                = scsiErrorBase + 6,            /* -7930 =                                      */
  743.     scsiUnused07                = scsiErrorBase + 7,            /* -7929 =                                      */
  744.     scsiUnused08                = scsiErrorBase + 8,            /* -7928 =                                      */
  745.     scsiUnableToTerminate        = scsiErrorBase + 9,            /* -7927 = Unable to Terminate I/O PB req         */
  746.     scsiSelectTimeout            = scsiErrorBase + 10,            /* -7926 = Target selection timeout             */
  747.     scsiCommandTimeout            = scsiErrorBase + 11,            /* -7925 = Command timeout                      */
  748.     scsiIdentifyMessageRejected    = scsiErrorBase + 12,            /* -7924 =                                      */
  749.     scsiMessageRejectReceived    = scsiErrorBase + 13,            /* -7923 = Message reject received                 */
  750.     scsiSCSIBusReset            = scsiErrorBase + 14,            /* -7922 = SCSI bus reset sent/received         */
  751.     scsiParityError                = scsiErrorBase + 15,            /* -7921 = Uncorrectable parity error occured     */
  752.     scsiAutosenseFailed            = scsiErrorBase + 16,            /* -7920 = Autosense: Request sense cmd fail     */
  753.     scsiUnused11                = scsiErrorBase + 17,            /* -7919 =                                      */
  754.     scsiDataRunError            = scsiErrorBase + 18,            /* -7918 = Data overrun/underrun error          */
  755.     scsiUnexpectedBusFree        = scsiErrorBase + 19,            /* -7917 = Unexpected BUS free                     */
  756.     scsiSequenceFailed            = scsiErrorBase + 20,            /* -7916 = Target bus phase sequence failure     */
  757.     scsiWrongDirection            = scsiErrorBase + 21,            /* -7915 = Data phase was in wrong direction     */
  758.     scsiUnused16                = scsiErrorBase + 22,            /* -7914 =                                      */
  759.     scsiBDRsent                    = scsiErrorBase + 23,            /* -7913 = A SCSI BDR msg was sent to target     */
  760.     scsiTerminated                = scsiErrorBase + 24,            /* -7912 = PB request terminated by the host     */
  761.     scsiNoNexus                    = scsiErrorBase + 25,            /* -7911 = Nexus is not established             */
  762.     scsiCDBReceived                = scsiErrorBase + 26,            /* -7910 = The SCSI CDB has been received         */
  763.                                                                 /* Couldn't begin execution  30-3F */
  764.     scsiTooManyBuses            = scsiErrorBase + 48,            /* -7888 = Register failed because we're full    */
  765.     scsiBusy                    = scsiErrorBase + 49,            /* -7887 = SCSI subsystem is busy                 */
  766.     scsiProvideFail                = scsiErrorBase + 50,            /* -7886 = Unable to provide requ. capability    */
  767.     scsiDeviceNotThere            = scsiErrorBase + 51,            /* -7885 = SCSI device not installed/there      */
  768.     scsiNoHBA                    = scsiErrorBase + 52,            /* -7884 = No HBA detected Error                 */
  769.     scsiDeviceConflict            = scsiErrorBase + 53,            /* -7883 = sorry, max 1 refNum per DeviceIdent     */
  770.     scsiNoSuchXref                = scsiErrorBase + 54,            /* -7882 = no such RefNum xref                     */
  771.     scsiQLinkInvalid            = scsiErrorBase + 55,            /* -7881 = pre-linked PBs not supported            */
  772.                                                                 /*   (The QLink field was nonzero)                */
  773.                                                                 /* Parameter errors  40-7F */
  774.     scsiPBLengthError            = scsiErrorBase + 64,            /* -7872 = (scsiPBLength is insuf'ct/invalid     */
  775.     scsiFunctionNotAvailable    = scsiErrorBase + 65,            /* -7871 = The requ. func is not available      */
  776.     scsiRequestInvalid            = scsiErrorBase + 66,            /* -7870 = PB request is invalid                 */
  777.     scsiBusInvalid                = scsiErrorBase + 67,            /* -7869 = Bus ID supplied is invalid              */
  778.     scsiTIDInvalid                = scsiErrorBase + 68,            /* -7868 = Target ID supplied is invalid         */
  779.     scsiLUNInvalid                = scsiErrorBase + 69,            /* -7867 = LUN supplied is invalid              */
  780.     scsiIDInvalid                = scsiErrorBase + 70,            /* -7866 = The initiator ID is invalid          */
  781.     scsiDataTypeInvalid            = scsiErrorBase + 71,            /* -7865 = scsiDataType requested not supported */
  782.     scsiTransferTypeInvalid        = scsiErrorBase + 72,            /* -7864 = scsiTransferType field is too high     */
  783.     scsiCDBLengthInvalid        = scsiErrorBase + 73            /* -7863 = scsiCDBLength field is too big         */
  784. };
  785.  
  786. /* New errors for SCSI Family         */
  787.  
  788. enum {
  789.     kSCSITargetProbeInvalidState = scsiErrorBase + 74,            /* -7862 = bus prober internal software error     */
  790.     scsiBadObjectID                = scsiErrorBase + 75,            /* -7861 = bad object ID to send message        */
  791.     scsiBadDataLength            = scsiErrorBase + 76,            /* -7860 = a zero data length in PB             */
  792.     scsiPartialPrepared            = scsiErrorBase + 77,            /* -7859 = could not do full prepare mem for I/O*/
  793.     scsiBadPBSize                = scsiPBLengthError,            /* -7872 = Incorrect parameter block size       */
  794.     scsiInvalidMsgType            = scsiErrorBase + 78,            /* -7858 = Invalid message type          */
  795.     scsiInvalidRegID            = scsiErrorBase + 79,            /* -7857 = Invalid registry Entry ID      */
  796.     scsiBadConnID                = scsiErrorBase + 80,            /* -7856 = Bad Connection ID              */
  797.     scsiBadIOTag                = scsiErrorBase + 81,            /* -7855 = Bad IO Tag                    */
  798.     scsiIOInProgress            = scsiErrorBase + 82,            /* -7854 = Can't close conn, IO in prog    */
  799.     scsiTargetReserved            = scsiErrorBase + 83,            /* -7853 = Target already reserved        */
  800.     scsiTargetInUsed            = scsiErrorBase + 84,            /* -7852 = Target is in used can't resv    */
  801.     scsiNoReserveOnBus            = scsiErrorBase + 85,            /* -7851 = Can't reserved on bus        */
  802.     scsiBadConnType                = scsiErrorBase + 86            /* -7850 = Bad connection type            */
  803. };
  804.  
  805.  
  806. enum {
  807.     scsiExecutionErrors            = scsiErrorBase,
  808.     scsiNotExecutedErrors        = scsiTooManyBuses,
  809.     scsiParameterErrors            = scsiPBLengthError
  810. };
  811.  
  812. /* Defines for the scsiResultFlags field */
  813.  
  814. enum {
  815.     scsiSIMQFrozen                = 0x0001,                        /* The SIM queue is frozen w/this err            */
  816.     scsiAutosenseValid            = 0x0002,                        /* Autosense data valid for target              */
  817.     scsiBusNotFree                = 0x0004                        /* At time of callback, SCSI bus is not free    */
  818. };
  819.  
  820. /* Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function */
  821.  
  822. enum {
  823.     kbSCSIDisableAutosense        = 29,                            /* Disable auto sense feature                     */
  824.     kbSCSIFlagReservedA            = 28,                            /*                                              */
  825.     kbSCSIFlagReserved0            = 27,                            /*                                              */
  826.     kbSCSICDBLinked                = 26,                            /* The PB contains a linked CDB                    */
  827.     kbSCSIQEnable                = 25,                            /* Target queue actions are enabled                */
  828.     kbSCSICDBIsPointer            = 24,                            /* The CDB field contains a pointer                */
  829.     kbSCSIFlagReserved1            = 23,                            /*                                                 */
  830.     kbSCSIInitiateSyncData        = 22,                            /* Attempt Sync data xfer and SDTR                */
  831.     kbSCSIDisableSyncData        = 21,                            /* Disable sync, go to async                    */
  832.     kbSCSISIMQHead                = 20,                            /* Place PB at the head of SIM Q                */
  833.     kbSCSISIMQFreeze            = 19,                            /* Return the SIM Q to frozen state                */
  834.     kbSCSISIMQNoFreeze            = 18,                            /* Disallow SIM Q freezing                        */
  835.     kbSCSIDoDisconnect            = 17,                            /* Definitely do disconnect                        */
  836.     kbSCSIDontDisconnect        = 16,                            /* Definitely don't disconnect                    */
  837.     kbSCSIDataReadyForDMA        = 15,                            /* Data buffer(s) are ready for DMA                */
  838.     kbSCSIFlagReserved3            = 14,                            /*                                                 */
  839.     kbSCSIDataPhysical            = 13,                            /* SG/Buffer data ptrs are physical                */
  840.     kbSCSISensePhysical            = 12,                            /* Autosense buffer ptr is physical                */
  841.     kbSCSIFlagReserved5            = 11,                            /*                                                 */
  842.     kbSCSIFlagReserved6            = 10,                            /*                                                 */
  843.     kbSCSIFlagReserved7            = 9,                            /*                                                 */
  844.     kbSCSIFlagReserved8            = 8,                            /*                                                 */
  845.     kbSCSIDataBufferValid        = 7,                            /* Data buffer valid                            */
  846.     kbSCSIStatusBufferValid        = 6,                            /* Status buffer valid                             */
  847.     kbSCSIMessageBufferValid    = 5,                            /* Message buffer valid                            */
  848.     kbSCSIFlagReserved9            = 4                                /*                                              */
  849. };
  850.  
  851. /* Defines for the bit masks of the scsiFlags field */
  852.  
  853. enum {
  854.     scsiDirectionMask            = 0xC0000000,                    /* Data direction mask                        */
  855.     scsiDirectionNone            = 0xC0000000,                    /* Data direction (11: no data)                */
  856.     scsiDirectionReserved        = 0x00000000,                    /* Data direction (00: reserved)            */
  857.     scsiDirectionOut            = 0x80000000,                    /* Data direction (10: DATA OUT)            */
  858.     scsiDirectionIn                = 0x40000000,                    /* Data direction (01: DATA IN)                */
  859.     scsiDisableAutosense        = 0x20000000,                    /* Disable auto sense feature                */
  860.     scsiFlagReservedA            = 0x10000000,                    /*                                             */
  861.     scsiFlagReserved0            = 0x08000000,                    /*                                             */
  862.     scsiCDBLinked                = 0x04000000,                    /* The PB contains a linked CDB                */
  863.     scsiQEnable                    = 0x02000000,                    /* Target queue actions are enabled            */
  864.     scsiCDBIsPointer            = 0x01000000,                    /* The CDB field contains a pointer            */
  865.     scsiFlagReserved1            = 0x00800000,                    /*                                             */
  866.     scsiInitiateSyncData        = 0x00400000,                    /* Attempt Sync data xfer and SDTR            */
  867.     scsiDisableSyncData            = 0x00200000,                    /* Disable sync, go to async                */
  868.     scsiSIMQHead                = 0x00100000,                    /* Place PB at the head of SIM Q            */
  869.     scsiSIMQFreeze                = 0x00080000,                    /* Return the SIM Q to frozen state            */
  870.     scsiSIMQNoFreeze            = 0x00040000,                    /* Disallow SIM Q freezing                    */
  871.     scsiDoDisconnect            = 0x00020000,                    /* Definitely do disconnect                    */
  872.     scsiDontDisconnect            = 0x00010000,                    /* Definitely don't disconnect                */
  873.     scsiDataReadyForDMA            = 0x00008000,                    /* Data buffer(s) are ready for DMA            */
  874.     scsiFlagReserved3            = 0x00004000,                    /*  */
  875.     scsiDataPhysical            = 0x00002000,                    /* SG/Buffer data ptrs are physical            */
  876.     scsiSensePhysical            = 0x00001000,                    /* Autosense buffer ptr is physical            */
  877.     scsiFlagReserved5            = 0x00000800,                    /*                                          */
  878.     scsiFlagReserved6            = 0x00000400,                    /*                                             */
  879.     scsiFlagReserved7            = 0x00000200,                    /*                                             */
  880.     scsiFlagReserved8            = 0x00000100                    /*                                             */
  881. };
  882.  
  883. /* bit masks for the scsiIOFlags field in SCSIExecIOPB */
  884.  
  885. enum {
  886.     scsiNoParityCheck            = 0x0002,                        /* disable parity checking                             */
  887.     scsiDisableSelectWAtn        = 0x0004,                        /* disable select w/Atn                              */
  888.     scsiSavePtrOnDisconnect        = 0x0008,                        /* do SaveDataPointer upon Disconnect msg             */
  889.     scsiNoBucketIn                = 0x0010,                        /* don't bit bucket in during this I/O                 */
  890.     scsiNoBucketOut                = 0x0020,                        /* don't bit bucket out during this I/O             */
  891.     scsiDisableWide                = 0x0040,                        /* disable wide transfer negotiation                 */
  892.     scsiInitiateWide            = 0x0080,                        /* initiate wide transfer negotiation                 */
  893.     scsiRenegotiateSense        = 0x0100,                        /* renegotiate sync/wide before issuing autosense     */
  894.     scsiDisableDiscipline        = 0x0200,                        /* disable parameter checking on SCSIExecIO calls    */
  895.     scsiIOFlagReserved0080        = 0x0080,                        /*                                                  */
  896.     scsiIOFlagReserved8000        = 0x8000                        /*                                                     */
  897. };
  898.  
  899. /* Defines for the Bus Inquiry PB fields. */
  900. /* scsiHBAInquiry field bits */
  901.  
  902. enum {
  903.     scsiBusMDP                    = 0x80,                            /* Supports Modify Data Pointer message                        */
  904.     scsiBusWide32                = 0x40,                            /* Supports 32 bit wide SCSI                                */
  905.     scsiBusWide16                = 0x20,                            /* Supports 16 bit wide SCSI                                */
  906.     scsiBusSDTR                    = 0x10,                            /* Supports Sync Data Transfer Req message                    */
  907.     scsiBusLinkedCDB            = 0x08,                            /* Supports linked CDBs                                        */
  908.     scsiBusTagQ                    = 0x02,                            /* Supports tag queue message                                */
  909.     scsiBusSoftReset            = 0x01                            /* Supports soft reset                                        */
  910. };
  911.  
  912. /* Defines for the scsiDataType field */
  913.  
  914. enum {
  915.     scsiDataBuffer                = 0,                            /* single contiguous buffer supplied                  */
  916.     scsiDataTIB                    = 1,                            /* TIB supplied (ptr in scsiDataPtr)                 */
  917.     scsiDataSG                    = 2,                            /* scatter/gather list supplied                      */
  918.     scsiDataIOTable                = 3,                            /*#(7/11/95) Prepared by Block Storage              */
  919.     scsiDataMemList                = 4                                /* (2/6/96) Memory list*/
  920. };
  921.  
  922. /* scsiDataTypes field bits  */
  923. /*    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved */
  924.  
  925. enum {
  926.     scsiBusDataTIB                = (1 << scsiDataTIB),            /* TIB supplied (ptr in scsiDataPtr)        */
  927.     scsiBusDataBuffer            = (1 << scsiDataBuffer),        /* single contiguous buffer supplied         */
  928.     scsiBusDataSG                = (1 << scsiDataSG),            /* scatter/gather list supplied             */
  929.     scsiBusDataIOTable            = (1 << scsiDataIOTable),        /* (2/6/95) Prepare Memory for IO*/
  930.     scsiBusDataMemList            = (1 << scsiDataMemList),        /* (2/6/96) Memory list*/
  931.     scsiBusDataReserved            = 0x80000000                    /*                                           */
  932. };
  933.  
  934. /* scsiScanFlags field bits */
  935.  
  936. enum {
  937.     scsiBusScansDevices            = 0x80,                            /* Bus scans for and maintains device list            */
  938.     scsiBusScansOnInit            = 0x40,                            /* Bus scans performed at power-up/reboot            */
  939.     scsiBusLoadsROMDrivers        = 0x20                            /* may load ROM drivers to support targets             */
  940. };
  941.  
  942. /* scsiFeatureFlags field bits */
  943.  
  944. enum {
  945.     scsiBusInternalExternalMask    = 0x000000C0,                    /* bus internal/external mask                    */
  946.     scsiBusInternalExternalUnknown = 0x00000000,                /* not known whether bus is inside or outside     */
  947.     scsiBusInternalExternal        = 0x000000C0,                    /* bus goes inside and outside the box             */
  948.     scsiBusInternal                = 0x00000080,                    /* bus goes inside the box                         */
  949.     scsiBusExternal                = 0x00000040,                    /* bus goes outside the box                     */
  950.     scsiBusCacheCoherentDMA        = 0x00000020,                    /* DMA is cache coherent                         */
  951.     scsiBusOldCallCapable        = 0x00000010,                    /* SIM is old call capable                         */
  952.     scsiBusDifferential            = 0x00000004,                    /* Single Ended (0) or Differential (1)         */
  953.     scsiBusFastSCSI                = 0x00000002,                    /* HBA supports fast SCSI                         */
  954.     scsiBusDMAavailable            = 0x00000001                    /* DMA is available                             */
  955. };
  956.  
  957. /* scsiWeirdStuff field bits */
  958.  
  959. enum {
  960.     scsiOddDisconnectUnsafeRead1 = 0x0001,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind reads */
  961.     scsiOddDisconnectUnsafeWrite1 = 0x0002,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind writes */
  962.     scsiBusErrorsUnsafe            = 0x0004,                        /* Non-handshaked delays or disconnects during blind transfers may cause a crash */
  963.     scsiRequiresHandshake        = 0x0008,                        /* Non-handshaked delays or disconnects during blind transfers may cause data corruption */
  964.     scsiTargetDrivenSDTRSafe    = 0x0010,                        /* Targets which initiate synchronous negotiations are supported */
  965.     scsiOddCountForPhysicalUnsafe = 0x0020,                        /* If using physical addrs all counts must be even, and disconnects must be on even boundries */
  966.     scsiAbortCmdFixed            = 0x0040                        /* Set if abort command is fixed to properly make callbacks */
  967. };
  968.  
  969. /* scsiHBAslotType values */
  970.  
  971. enum {
  972.     scsiMotherboardBus            = 0x01,                            /* A built in Apple supplied bus                     */
  973.     scsiNuBus                    = 0x02,                            /* A SIM on a NuBus card                             */
  974.     scsiPDSBus                    = 0x03,                            /*    "  on a PDS card                                */
  975.     scsiPCIBus                    = 0x04,                            /*    "  on a PCI bus card                            */
  976.     scsiPCMCIABus                = 0x05,                            /*    "  on a PCMCIA card                            */
  977.     scsiFireWireBridgeBus        = 0x06                            /*    "  connected through a FireWire bridge        */
  978. };
  979.  
  980. #endif
  981. #if FOR_SYSTEM7_ONLY
  982. /* Defines for the scsiDriverFlags field (in SCSIDriverPB) */
  983.  
  984. enum {
  985.     scsiDeviceSensitive            = 0x0001,                        /* Only driver should access this device                */
  986.     scsiDeviceNoOldCallAccess    = 0x0002                        /* no old call access to this device                     */
  987. };
  988.  
  989. /* SCSI status*/
  990.  
  991. enum {
  992.     scsiStatGood                = 0x00,                            /* Good Status*/
  993.     scsiStatCheckCondition        = 0x02,                            /* Check Condition*/
  994.     scsiStatConditionMet        = 0x04,                            /* Condition Met*/
  995.     scsiStatBusy                = 0x08,                            /* Busy*/
  996.     scsiStatIntermediate        = 0x10,                            /* Intermediate*/
  997.     scsiStatIntermedMet            = 0x14,                            /* Intermediate - Condition Met*/
  998.     scsiStatResvConflict        = 0x18,                            /* Reservation conflict*/
  999.     scsiStatTerminated            = 0x20,                            /* Command terminated*/
  1000.     scsiStatQFull                = 0x28                            /* Queue full*/
  1001. };
  1002.  
  1003. /* SCSI messages*/
  1004.  
  1005. enum {
  1006.     kCmdCompleteMsg                = 0,
  1007.     kExtendedMsg                = 1,                            /* 0x01*/
  1008.     kSaveDataPointerMsg            = 2,                            /* 0x02*/
  1009.     kRestorePointersMsg            = 3,                            /* 0x03*/
  1010.     kDisconnectMsg                = 4,                            /* 0x04*/
  1011.     kInitiatorDetectedErrorMsg    = 5,                            /* 0x05*/
  1012.     kAbortMsg                    = 6,                            /* 0x06*/
  1013.     kMsgRejectMsg                = 7,                            /* 0x07*/
  1014.     kNoOperationMsg                = 8,                            /* 0x08*/
  1015.     kMsgParityErrorMsg            = 9,                            /* 0x09*/
  1016.     kLinkedCmdCompleteMsg        = 10,                            /* 0x0a*/
  1017.     kLinkedCmdCompleteWithFlagMsg = 11,                            /* 0x0b*/
  1018.     kBusDeviceResetMsg            = 12,                            /* 0x0c*/
  1019.     kAbortTagMsg                = 13,                            /* 0x0d*/
  1020.     kClearQueueMsg                = 14,                            /* 0x0e*/
  1021.     kInitiateRecoveryMsg        = 15,                            /* 0x0f*/
  1022.     kReleaseRecoveryMsg            = 16,                            /* 0x10*/
  1023.     kTerminateIOProcessMsg        = 17,                            /* 0x11*/
  1024.     kSimpleQueueTag                = 0x20,                            /* 0x20*/
  1025.     kHeadOfQueueTagMsg            = 0x21,                            /* 0x21*/
  1026.     kOrderedQueueTagMsg            = 0x22,                            /* 0x22*/
  1027.     kIgnoreWideResidueMsg        = 0x23                            /* 0x23*/
  1028. };
  1029.  
  1030. #endif
  1031. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  1032. /*  SIMInitInfo PB */
  1033. /* directions are for SCSIRegisterBus call ( -> parm, <- result)             */
  1034. struct SIMInitInfo {
  1035.     Ptr                             SIMstaticPtr;                /* <- alloc. ptr to the SIM's static vars                 */
  1036.     long                             staticSize;                    /* -> num bytes SIM needs for static vars                 */
  1037.     SIMInitUPP                         SIMInit;                    /* -> pointer to the SIM init routine                     */
  1038.     SIMActionUPP                     SIMAction;                    /* -> pointer to the SIM action routine                 */
  1039.     SCSIInterruptUPP                 SIM_ISR;                    /*       reserved                                             */
  1040.     SCSIInterruptUPP                 SIMInterruptPoll;            /* -> pointer to the SIM interrupt poll routine            */
  1041.     SIMActionUPP                     NewOldCall;                    /* -> pointer to the SIM NewOldCall routine                */
  1042.     UInt16                             ioPBSize;                    /* -> size of SCSI_IO_PBs required for this SIM            */
  1043.     Boolean                         oldCallCapable;                /* -> true if this SIM can handle old-API calls            */
  1044.     UInt8                             simInfoUnused1;                /*       reserved                                            */
  1045.     long                             simInternalUse;                /* xx not affected or viewed by XPT                        */
  1046.     SCSIUPP                         XPT_ISR;                    /*    reserved                                            */
  1047.     SCSIUPP                         EnteringSIM;                /* <- ptr to the EnteringSIM routine                    */
  1048.     SCSIUPP                         ExitingSIM;                    /* <- ptr to the ExitingSIM routine                        */
  1049.     SCSIMakeCallbackUPP             MakeCallback;                /* <- the XPT layer's SCSIMakeCallback routine            */
  1050.     UInt16                             busID;                        /* <- bus number for the registered bus                    */
  1051.     UInt8                             simSlotNumber;                /* <- Magic cookie to place in scsiHBASlotNumber (PCI)    */
  1052.     UInt8                             simSRsrcID;                    /* <- Magic cookie to place in scsiSIMsRsrcID     (PCI)    */
  1053.     Ptr                             simRegEntry;                /* -> The SIM's RegEntryIDPtr                     (PCI)    */
  1054. };
  1055. typedef struct SIMInitInfo SIMInitInfo;
  1056.  
  1057. /* Glue between SCSI calls and SCSITrap format */
  1058.  
  1059. enum {
  1060.     xptSCSIAction                = 0x0001,
  1061.     xptSCSIRegisterBus            = 0x0002,
  1062.     xptSCSIDeregisterBus        = 0x0003,
  1063.     xptSCSIReregisterBus        = 0x0004,
  1064.     xptSCSIKillXPT                = 0x0005,                        /* kills Mini-XPT after transition */
  1065.     xptSCSIInitialize            = 0x000A                        /* Initialize the SCSI manager */
  1066. };
  1067.  
  1068. /* moveq #kSCSIx, D0;  _SCSIAtomic */
  1069.  
  1070. #if GENERATING68K && !GENERATINGCFM
  1071. #pragma parameter __D0 SCSIAction(__A0)
  1072. #endif
  1073. extern pascal OSErr SCSIAction(SCSI_PB *parameterBlock)
  1074.  TWOWORDINLINE(0x7001, 0xA089);
  1075.  
  1076.  
  1077. #if GENERATING68K && !GENERATINGCFM
  1078. #pragma parameter __D0 SCSIRegisterBus(__A0)
  1079. #endif
  1080. extern pascal OSErr SCSIRegisterBus(SIMInitInfo *parameterBlock)
  1081.  TWOWORDINLINE(0x7002, 0xA089);
  1082.  
  1083.  
  1084. #if GENERATING68K && !GENERATINGCFM
  1085. #pragma parameter __D0 SCSIDeregisterBus(__A0)
  1086. #endif
  1087. extern pascal OSErr SCSIDeregisterBus(SCSI_PB *parameterBlock)
  1088.  TWOWORDINLINE(0x7003, 0xA089);
  1089.  
  1090.  
  1091. #if GENERATING68K && !GENERATINGCFM
  1092. #pragma parameter __D0 SCSIReregisterBus(__A0)
  1093. #endif
  1094. extern pascal OSErr SCSIReregisterBus(SIMInitInfo *parameterBlock)
  1095.  TWOWORDINLINE(0x7004, 0xA089);
  1096.  
  1097.  
  1098. #if GENERATING68K && !GENERATINGCFM
  1099. #pragma parameter __D0 SCSIKillXPT(__A0)
  1100. #endif
  1101. extern pascal OSErr SCSIKillXPT(SIMInitInfo *parameterBlock)
  1102.  TWOWORDINLINE(0x7005, 0xA089);
  1103.  
  1104. extern OSStatus SCSIInitBFPI(void );
  1105.  
  1106. #endif
  1107. #if FOR_SYSTEM8_PREEMPTIVE
  1108. /*
  1109.     File:        SCSIConn.h
  1110.  
  1111.     Contains:    Connection Based parameter checking
  1112.  
  1113.     Version:    0.1
  1114.  
  1115.     Written by:    Darryl Chan
  1116.  
  1117.     Copyright:    © 1995-1996 by Apple Computer, Inc., all rights reserved.
  1118.  
  1119.     File Ownership:
  1120.  
  1121.         DRI:                Darryl Chan
  1122.  
  1123.         Other Contact:        Stanford Au
  1124.  
  1125.         Technology:            IO Group
  1126.  
  1127.     Writers:
  1128.  
  1129.         (DC)    Darryl Chan
  1130.  
  1131.     Change History (most recent first):
  1132.  
  1133.          <4>     1/25/96    DC        Integrate to D11 - name registry changes
  1134.          <3>     1/18/96    DC        Split file to public and private interfaces and converting to
  1135.                                     MrC.
  1136.          <2>     1/15/96    DC        Add more commands
  1137.          <1>      1/3/96    DC        First checked in.
  1138.  
  1139. */
  1140. typedef UInt32 ConnectionType;
  1141. typedef ObjectID ConnectionID;
  1142. typedef MessageID SCSIExecIOTag;
  1143.  
  1144. enum {
  1145.     kMaxAutoSenseByteCount        = 255                            /* max sense byte buffer size*/
  1146. };
  1147.  
  1148. /*        values for 'type's of connection (UInt16)*/
  1149.  
  1150. enum {
  1151.     kReservedAccess                = 0x0100,                        /* Reserved Access */
  1152.     kSharedAccess                = 0x0200                        /* Shared Access*/
  1153. };
  1154.  
  1155. struct SCSIDataObject {
  1156.     UInt8 *                            scsiDataPtr;
  1157.     SInt32                             scsiDataLength;
  1158.     UInt16                             scsiDataType;
  1159.     UInt16                             scsiSGListCount;
  1160. };
  1161. typedef struct SCSIDataObject SCSIDataObject;
  1162.  
  1163. struct SCSICDBObject {
  1164.     UInt16                             scsiCDBLength;
  1165.     CDB                             scsiCDB;
  1166. };
  1167. typedef struct SCSICDBObject SCSICDBObject;
  1168.  
  1169. struct SCSIFlagsObject {
  1170.     UInt32                             scsiFlags;
  1171.     UInt16                             scsiIOFlags;
  1172.     UInt16                             scsiTransferType;
  1173. };
  1174. typedef struct SCSIFlagsObject SCSIFlagsObject;
  1175.  
  1176. struct SCSIExecIOResult {
  1177.     OSStatus                         scsiResult;
  1178.     UInt16                             scsiResultFlags;
  1179.     UInt16                             scsiSenseLength;            /* the actual sense length returned*/
  1180.     SInt32                             scsiDataResidual;            /* residual data length*/
  1181.     SCSIExecIOTag                     ioTag;
  1182.     UInt8                             scsiSense[255];                /* maximum sense buffer*/
  1183.     UInt8                             scsiSCSIstatus;
  1184. };
  1185. typedef struct SCSIExecIOResult SCSIExecIOResult;
  1186.  
  1187. struct SCSIIOOptionsObject {
  1188.     UInt32                             scsiFlags;
  1189.     UInt32                             scsiIOFlags;
  1190. };
  1191. typedef struct SCSIIOOptionsObject SCSIIOOptionsObject;
  1192.  
  1193. struct SCSIHandshakeObject {
  1194.     UInt16                             scsiHandshake[8];
  1195. };
  1196. typedef struct SCSIHandshakeObject SCSIHandshakeObject;
  1197.  
  1198. struct SCSIBusInfo {
  1199.     UInt16                             scsiEngineCount;            /* <- Number of engines on HBA                         */
  1200.     UInt16                             scsiMaxTransferType;        /* <- Number of transfer types for this HBA            */
  1201.  
  1202.     UInt32                             scsiDataTypes;                /* <- which data types are supported by this SIM     */
  1203.  
  1204.     UInt32                             scsiBIReserved4;            /* <-                                                  */
  1205.  
  1206.     UInt32                             scsiFeatureFlags;            /* <- Supported features flags field                 */
  1207.  
  1208.     UInt8                             scsiVersionNumber;            /* <- Version number for the SIM/HBA                 */
  1209.     UInt8                             scsiHBAInquiry;                /* <- Mimic of INQ byte 7 for the HBA                 */
  1210.     UInt8                             scsiTargetModeFlags;        /* <- Flags for target mode support                 */
  1211.     UInt8                             scsiScanFlags;                /* <- Scan related feature flags                     */
  1212.  
  1213.     UInt32                             scsiSIMPrivatesPtr;            /* <- Ptr to SIM private data area                     */
  1214.     UInt32                             scsiSIMPrivatesSize;        /* <- Size of SIM private data area                 */
  1215.     UInt32                             scsiAsyncFlags;                /* <- Event cap. for Async Callback                 */
  1216.  
  1217.     UInt8                             scsiHiBusID;                /* <- Highest path ID in the subsystem              */
  1218.     UInt8                             scsiInitiatorID;            /* <- ID of the HBA on the SCSI bus                 */
  1219.     UInt16                             scsiBIReserved0;            /*                                                    */
  1220.  
  1221.     UInt32                             scsiBIReserved1;            /* <-                                                  */
  1222.     UInt32                             scsiFlagsSupported;            /* <- which scsiFlags are supported                 */
  1223.  
  1224.     UInt16                             scsiIOFlagsSupported;        /* <- which scsiIOFlags are supported                 */
  1225.     UInt16                             scsiWeirdStuff;                /* <-                                                 */
  1226.     UInt16                             scsiMaxTarget;                /* <- maximum Target number supported                 */
  1227.     UInt16                             scsiMaxLUN;                    /* <- maximum Logical Unit number supported         */
  1228.  
  1229.     char                             scsiSIMVendor[16];            /* <- Vendor ID of SIM (or XPT if bus<FF)         */
  1230.     char                             scsiHBAVendor[16];            /* <- Vendor ID of the HBA                         */
  1231.     char                             scsiControllerFamily[16];    /* <- Family of SCSI Controller                 */
  1232.     char                             scsiControllerType[16];        /* <- Specific Model of SCSI Controller used     */
  1233.  
  1234.     char                             scsiXPTversion[4];            /* <- version number of XPT                         */
  1235.     char                             scsiSIMversion[4];            /* <- version number of SIM                         */
  1236.     char                             scsiHBAversion[4];            /* <- version number of HBA                         */
  1237.  
  1238.     UInt8                             scsiHBAslotType;            /* <- type of "slot" that this HBA is in            */
  1239.     UInt8                             scsiHBAslotNumber;            /* <- slot number of this HBA                         */
  1240.     UInt16                             scsiSIMsRsrcID;                /* <- resource ID of this SIM                         */
  1241.  
  1242.     UInt16                             scsiBIReserved3;            /* <-                                                 */
  1243.                                                                 /*    UInt16        scsiAdditionalLength;    |* <- additional BusInquiry PB len                    *|*/
  1244. };
  1245. typedef struct SCSIBusInfo SCSIBusInfo;
  1246.  
  1247.  
  1248. enum {
  1249.     kSCSIDeviceTypeSize            = 9,                            /* number of characters for device type*/
  1250.     kSCSIAllBus                    = 0xFF                            /* search all bus*/
  1251. };
  1252.  
  1253. typedef char DeviceType[9];
  1254. /* this replaces SCSIDevList*/
  1255. struct SCSIIOIteratorData {
  1256.     IOCommonInfo                     deviceInfo;
  1257.     DeviceIdent                     deviceID;
  1258.     DeviceType                         deviceType;
  1259. };
  1260. typedef struct SCSIIOIteratorData SCSIIOIteratorData;
  1261.  
  1262.  
  1263. enum {
  1264.     scsiVERSION                    = 80
  1265. };
  1266.  
  1267. /*
  1268. _____________________________________________________________________
  1269.         Client type used to identify the type of client we are dealing 
  1270.         with.
  1271. _____________________________________________________________________
  1272. */
  1273. typedef UInt8 ClientType;
  1274. /*     for Client type*/
  1275.  
  1276. enum {
  1277.     kUserClient                    = 0x02,
  1278.     kPriviClient                = 0x01,
  1279.     kBlueUserClient                = 0x06
  1280. };
  1281.  
  1282. /*
  1283.     
  1284.     New command to get Registry Entry ID for the SCSI Plugin
  1285. */
  1286.  
  1287. enum {
  1288.     SCSIGetRegEntryID            = 0x89                            /* Return a copy of the System Registry    */
  1289. };
  1290.  
  1291. struct SCSIGetRegEntryIDPB {
  1292.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  1293.     short                             scsiReserved1;
  1294.     UInt16                             scsiPBLength;
  1295.     UInt8                             scsiFunctionCode;
  1296.     UInt8                             scsiReserved2;
  1297.     OSErr                             scsiResult;
  1298.     DeviceIdent                     scsiDevice;
  1299.     void *                            scsiCompletion;
  1300.     UInt32                             scsiFlags;
  1301.     BytePtr                         scsiDriverStorage;
  1302.     Ptr                             scsiXPTprivate;
  1303.     long                             scsiReserved3;
  1304.     RegEntryRef                     scsiRegEntryID;                /* A copy of the System Registry ID    */
  1305. };
  1306. typedef struct SCSIGetRegEntryIDPB SCSIGetRegEntryIDPB;
  1307.  
  1308. /*  Functions declarations*/
  1309. extern OSStatus SCSIOpenConnection(RegEntryRef *regID, ConnectionType connType, ConnectionID *connID);
  1310.  
  1311. extern OSStatus SCSICloseConnection(ConnectionID connID);
  1312.  
  1313. extern OSStatus SCSIExecIOSyncCmd(ConnectionID connID, SCSIDataObject dataObject, SCSICDBObject cdbObject, SCSIFlagsObject flagsObject, SCSIExecIOResult *resultBuffer, SCSIExecIOTag *ioTag);
  1314.  
  1315. extern OSStatus SCSIExecIOAsyncCmd(ConnectionID connID, KernelNotification *kernelNot, SCSIDataObject dataObject, SCSICDBObject cdbObject, SCSIFlagsObject flagsObject, SCSIExecIOResult *resultBuffer, SCSIExecIOTag *ioTag);
  1316.  
  1317. extern OSStatus SCSIAbortIOCmd(ConnectionID connID, SCSIExecIOTag ioTag);
  1318.  
  1319. extern OSStatus SCSITerminateIOCmd(ConnectionID connID, SCSIExecIOTag ioTag);
  1320.  
  1321. extern OSStatus SCSIReleaseQCmd(ConnectionID connID);
  1322.  
  1323. extern OSStatus SCSIClearQueue(ConnectionID connID);
  1324.  
  1325. extern OSStatus SCSIBusResetSync(ConnectionID connID, OSStatus *resultBuffer);
  1326.  
  1327. extern OSStatus SCSIBusResetAsync(ConnectionID connID, KernelNotification *kernelNot, OSStatus *resultBuffer);
  1328.  
  1329. extern OSStatus SCSIDeviceResetSync(ConnectionID connID, OSStatus *resultBuffer);
  1330.  
  1331. extern OSStatus SCSIDeviceResetAsync(ConnectionID connID, KernelNotification *kernelNot, OSStatus *resultBuffer);
  1332.  
  1333. extern OSStatus SCSIBusGetDeviceData(UInt8 *bus, UInt32 reqCount, UInt32 *actCount, SCSIIOIteratorData *list);
  1334.  
  1335. extern OSStatus SCSIBusInquiryCmd(ConnectionID connID, SCSIBusInfo *resultBuffer);
  1336.  
  1337. extern OSStatus SCSISetHandshake(ConnectionID connID, SCSIHandshakeObject handshake);
  1338.  
  1339. extern OSStatus SCSISetTimeout(ConnectionID connID, Duration scsiTimeout, UInt16 scsiSelectTimeout);
  1340.  
  1341. extern OSStatus SCSISetIOOptions(ConnectionID connID, SCSIIOOptionsObject ioOptions);
  1342.  
  1343. extern OSStatus SCSIInitFPI(void );
  1344.  
  1345. extern OSStatus SCSIServer(SCSI_PB *scsiPB, KernelNotification *kernelNot);
  1346.  
  1347. extern OSStatus SCSIExecIOControlSyncCmd(ConnectionID connID, SCSIDataObject dataObject, DeviceIdent deviceID, SCSICDBObject cdbObject, SCSIFlagsObject flagsObject, SCSIExecIOResult *resultBuffer, SCSIExecIOTag *ioTag);
  1348.  
  1349. extern OSStatus SCSIExecIOControlAsyncCmd(ConnectionID connID, KernelNotification *kernelNot, SCSIDataObject dataObject, DeviceIdent deviceID, SCSICDBObject cdbObject, SCSIFlagsObject flagsObject, SCSIExecIOResult *resultBuffer, SCSIExecIOTag *ioTag);
  1350.  
  1351. #endif
  1352.  
  1353. #if PRAGMA_ALIGN_SUPPORTED
  1354. #pragma options align=reset
  1355. #endif
  1356.  
  1357. #if PRAGMA_IMPORT_SUPPORTED
  1358. #pragma import off
  1359. #endif
  1360.  
  1361. #ifdef __cplusplus
  1362. }
  1363. #endif
  1364.  
  1365. #endif /* __SCSI__ */
  1366.  
  1367.